package com.yj.wisemoms.data;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yj.wisemoms.Base.NewsBase;

public class Newsdata {
	
	private static Newsdata uniqueInstance;  
	
	public static Newsdata getInstance(){  
		if(uniqueInstance == null){  
			uniqueInstance = new Newsdata();  
		}  
		return uniqueInstance;  
	}  
	
	public boolean isNews = false;
	
	ObjectMapper mapper = new ObjectMapper();
	
	List<NewsBase> mNewsList;
	
	public void setNews(String NewsListData){
		
		try {
			mNewsList =  mapper.readValue(NewsListData,mapper.getTypeFactory().constructCollectionType(List.class, NewsBase.class));
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		isNews = true;
	}	
		
	public List<NewsBase> getNewsList(){
		return mNewsList;
	}
	
	
	
	
}

